package com.cilico;

import com.cilico.view.BaseView;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;

/**
 * 全局配置
 * @author lv.xiangan
 *
 */

public final class ConfigManager {
	// HTTP连接超时时间
	final static int TIMECONNECTTIMEOUT = 20000;
	// 界面下方statusbar的选中图标序号
	public static int STATUSBAR_INDEX;
	// 输入框键盘类型
	public final static int InputType_CLASS_TEXT = 0; // 文本（默认）
	public final static int InputType_VARIATION_PASSWORD = InputType_CLASS_TEXT + 1; // 星号密码
	public final static int InputType_DECIMAL = InputType_VARIATION_PASSWORD + 1; // 小数
	public final static int InputType_NUMBER = InputType_DECIMAL + 1; // 整数
	public final static int InputType_DATETIME = InputType_NUMBER + 1; // 日期
	public final static int InputType_PHONE = InputType_DATETIME + 1; // 电话
	public final static int InputType_VARIATION_VISIBLE_PASSWORD = InputType_PHONE + 1; // 可见密码
	public final static int InputType_PLUS_DIGIT = InputType_VARIATION_VISIBLE_PASSWORD + 1; // 正整数："0-9"，
	public final static int InputType_PLUS_DECIMAL = InputType_PLUS_DIGIT + 1; // 正小数:"0-9" 和 "."
	/**不可以输入中文*/
	public final static int InputType_NO_CHINESE = InputType_PLUS_DECIMAL +1;
	
	public final static int COLOR_DKGREEN = 0xFF02400F;
	public final static int COLOR_GREEN = Color.GREEN;
	public final static int COLOR_GRAY = Color.GRAY;
	// 单选按钮中圆阴影着色
	public final static int COLOR_DKGRAY = Color.DKGRAY;
	public final static int COLOR_WHITE = Color.WHITE;
	// 单选按钮最外层园填充色
	public final static int COLOR_OUTERMOST = Color.WHITE;
	// 单选按钮最小半径定为15像素
	public final static int minRadius_ = 15;
	// 当前界面引用对象
	public static BaseView currentView_;
	// 读取进度提示字体大小
	public static int SIZE_IMGWAITLOAD = 15;
	// tabbar控件字体大小
	public static int SIZE_TABBAR = 11;
	// 默认小号字体大小
	public static int SIZE_SMALL = 20;
	//九宫格字体
	public static int SIZE_MAIN = 10;
	// 默认中号字体大小
	public static int SIZE_MEDIUM = 24;
	// 默认大好字体大小
	public static int SIZE_LARGE = 30;
	// 固件版本号
	public static float SYSTEMVISION;
	// 设备唯一标识
	public static String DEVICETOKEN;
	// 控件存储项名结尾标志
	public static String SAVENEND = "~=n#*";
	// 控件存储项值结尾标志
	public static String SAVEVEND = "^_v*#";
	// TMS是否清除了客户端的用户信息标志
	public static boolean TMS_CLEARED_USERINFO;
	// menu panels和status bars的，默认颜色
	public final static int DEFAULT_TRANSPARENCY = 0xa0000000;
	public final static int POIS_PER_SCREEN = 9;
	/**包名*/
	public static String PATH_ROOT = "/data/data/com.cilico";
	
	// 如果是打生产环境的包，则修改此变量为false；
	public static boolean IS_TEST = true;
	
	// 模拟器外网 9085 //9085---29C  9083--28
//    public static String SERVER_URI = "http://113.108.207.154:9085/";
//    public static String SERVER_URI = "http://10.2.33.23:80/";
	//内网地址http://192.168.1.118:8082/api/Waiterapi!index.html
	/**外网地址*/
	public static String NET_URL = "http://27.50.130.122:8081/";
	/**设置的IP地址*/
	public static String SET_HOST_URL = "";
	public static String SERVER_URI = "";
    /**接口*/
    public static String SERVER_IMP = "api/waiter/api!index.html";
    
    public static String CLIENT_HELLO = SERVER_URI + SERVER_IMP;
	public static String SERVER_URI_LOGIN = SERVER_URI + "phone/getui?";
	public static String LOGIN_URI = "phone_s/login?";// _s说明需要使用解密
	public static String COLLECTION_LIST_URI = "api/waiter/channel_s/";
	public static String GET_PIC_URI = "map/get_pic?";
	// 上传头像图片
	public static String UPLOAD_HEAD__PORTRAIT_URI = "upload/head_pic?";
	public static String DEFAULTTEXT = "点击这里输入……";
	public static String APP_USERAGENT;
	public static final boolean IMAGE_TRANSPARENCY = true;
	
	// 在HTTP传输中使用的客户端代理信息。XXX DO NOTE CHANGE THIS!!
	static final String makeUserAgent(String phoneModel, String version) {
		StringBuffer buf = new StringBuffer("cilico/");
		buf.append(version);
		buf.append("/");
		buf.append(phoneModel.toLowerCase());
		ConfigManager.APP_USERAGENT = buf.toString();
		return ConfigManager.APP_USERAGENT;
	}
	
	// 九宫格快捷地址
	public static final String[] mainMenuShortCut_ = {
	//       帮助           登陆             个人设置            点餐                   优惠信息                 专享特权
			"cilico_help", "cilico_login", "cilico_setting", "cilico_book_dinner", "cilico_discount_info", "cilico_vip" 
	};
	
	/** 
	 * 缓存未登录前要请求的链接和参数。
	 * 当用户在未登陆的状态下要进行个人化操作，页面
	 * 会先跳转到登陆页面，当用户登录成功后，客户端
	 * 会自动向服务端发起访问，请求下一页面。
	 */
	public static String preAction_ = null;
	/**
	 * 设置本地URL
	 * @author lvke
	 * Email: lvke@live.cn
	 * 2014-1-13上午11:07:05
	 */
	public static void initManager(BaseView bv){
		SharedPreferences preferences = bv.getSharedPreferences("com.cilico_preferences", Context.MODE_PRIVATE);
		boolean b = preferences.getBoolean("net", true);
		SET_HOST_URL = preferences.getString("set_host","");
		if (!b && SET_HOST_URL != null &&
				!SET_HOST_URL.equals("")) {
			if (!SET_HOST_URL.startsWith("http://")) {
				SET_HOST_URL = "http://" + SET_HOST_URL;
			}
			SET_HOST_URL = SET_HOST_URL + ":8082";//拼接端口号
			if (!SET_HOST_URL.endsWith("/")) {
				SET_HOST_URL = SET_HOST_URL +"/";
			}
			SERVER_URI = SET_HOST_URL;
			CLIENT_HELLO = SET_HOST_URL + SERVER_IMP;
			SERVER_URI_LOGIN = SET_HOST_URL + "phone/getui?";
		}else {
			SERVER_URI = NET_URL;
			CLIENT_HELLO = SERVER_URI + "api/api!main.html";
			SERVER_URI_LOGIN = SERVER_URI + "phone/getui?";
		}
	}

}
